$OpenBSD: patch-lib_rubygems_ext_builder_rb,v 1.2 2012/10/24 22:50:27 jeremy Exp $

Ugly hack to make --user-install option work.  Without this, when
a user uses gem install --user-install, it calls
/usr/bin/install -o root -g bin, which fails due to permission issues.
This removes the -o root -g bin, so it can succeed as a regular user.

--- lib/rubygems/ext/builder.rb.orig	Wed Oct  6 10:27:31 2010
+++ lib/rubygems/ext/builder.rb	Wed Oct  6 10:28:16 2010
@@ -19,6 +19,7 @@ class Gem::Ext::Builder
     mf = File.read('Makefile')
     mf = mf.gsub(/^RUBYARCHDIR\s*=\s*\$[^$]*/, "RUBYARCHDIR = #{dest_path}")
     mf = mf.gsub(/^RUBYLIBDIR\s*=\s*\$[^$]*/, "RUBYLIBDIR = #{dest_path}")
+    mf = mf.gsub(/-o root -g bin/, "") unless Process.euid == 0
 
     File.open('Makefile', 'wb') {|f| f.print mf}
 
